.TH std::basic_string_view::begin,std::basic_string_view::cbegin 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::basic_string_view::begin,std::basic_string_view::cbegin \- std::basic_string_view::begin,std::basic_string_view::cbegin

.SH Synopsis
   constexpr const_iterator begin() const noexcept;   \fI(since C++17)\fP
   constexpr const_iterator cbegin() const noexcept;  \fI(since C++17)\fP

   Returns an iterator to the first character of the view.

   range-begin-end.svg

.SH Parameters

   \fI(none)\fP

.SH Return value

   const_iterator to the first character.

.SH Complexity

   Constant.

.SH Example


// Run this code

 #include <concepts>
 #include <string_view>

 int main()
 {
     constexpr std::string_view str_view("abcd");

     constexpr auto begin = str_view.begin();
     constexpr auto cbegin = str_view.cbegin();
     static_assert(
         *begin == 'a' and
         *cbegin == 'a' and
         *begin == *cbegin and
         begin == cbegin and
         std::same_as<decltype(begin), decltype(cbegin)>);
 }

.SH See also

   end     returns an iterator to the end
   cend    \fI(public member function)\fP
   begin   returns an iterator to the beginning
   cbegin  \fI(public member function of std::basic_string<CharT,Traits,Allocator>)\fP
   \fI(C++11)\fP
